<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件学习</title>
</head>
<style>
    *{
        margin-top: 20px;
    }
    .dame1{
        height: 50px;
        background-color: deepskyblue;
    }
    .box1{
        padding: 5px;
        background-color: skyblue;
    }
    .box2{
        padding: 5px;
        background-color: orange;
    }
    .list{
        width: 200px;
        height: 200px;
        background-color: palevioletred;
        overflow: auto;//含有滚动条 自动判断是否有滚动条
    }
    li{
        height: 100px;
    }
</style>
<body>
<div id="root">
    <h2>欢迎来到{{name}}学习</h2>
<!--    阻止默认事件发生-->
    <a href="http://www.baidu.com" @click.prevent="showinfo">点击一下你试试</a>
<!--    阻止默认事件冒泡-->
    <div @click="showinfo" class="dame1">
        <button @click="showinfo.stop">点我提示信息</button>
    </div>
<!--    事件只触发一次-->
    <button @click.once="showinfo">点我提示信息</button>

<!--    上面重点，下面了解-->
<!--    事件的捕获模式-->
    <div class="box1" @click.capture="showmsg(1)">
        div1
        <div class="box2" @click="showmsg(2)">
            div2
        </div>
    </div>
    <div>
        <ul class="list" @scroll="demo1">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
    </div>
</div>
</body>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript">
    Vue.config.productionTip=false //阻止vue在启动时生成生产提示

    new Vue({
        el:'#root',
        data:{
            name:'xiaowang'
        },
       methods:{
            showinfo(e){
                alert('hellow')
            },
            showmsg(msg){
               console.log(msg)
            },
           demo1(){
               console.log('#')
           }
       }
    })
</script>
</html>